package com.zhentao.service.impl;




import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.mapper.UsersMapper;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.enums.AppHttpCodeEnum;
import com.zhentao.model.common.pojo.coupon.CdzExceptionalRetroaction;
import com.zhentao.model.common.pojo.dto.UsersDto;
import com.zhentao.model.common.pojo.income.CdzInviteRecord;
import com.zhentao.model.common.pojo.income.CdzUserIncome;
import com.zhentao.model.common.pojo.users.MassageParam;

import com.zhentao.model.common.pojo.users.param.Param;
import com.zhentao.model.common.pojo.users.param.UserBalanceParam;
import com.zhentao.model.common.user.Users;
import com.zhentao.service.IUsersService;
import com.zhentao.userLocal.UserThreadLocalUtil;
import lombok.SneakyThrows;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import utils.ChargeAliyunMsgUtils;
import utils.JwtService;

import java.util.*;
import java.util.concurrent.TimeUnit;

import static com.zhentao.model.common.enums.AppHttpCodeEnum.PARAM_REQUIRE;
import static com.zhentao.model.common.enums.AppHttpCodeEnum.SUCCESS;
import static com.zhentao.user.UserCommon.*;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mp
 * @since 2024-12-17
 */
@Service
// 该类是服务层实现类，继承了ServiceImpl并且实现了IUsersService接口，用于处理用户相关业务逻辑
public class UsersServiceImpl implements IUsersService{
@Autowired
private UsersMapper usersMapper;

    @Override
    public ResponseResult selectAll() {
        List<Users> list = usersMapper.selectlist();
        list.forEach(users -> {
            users.setPassword("******");
        });
        return ResponseResult.okResult(list);
    }

    @Override
    public ResponseResult updateex(Integer id) {
        if(id==null){
            return ResponseResult.errorResult(400,"id不能为空");
        }
        Users users=usersMapper.selectUserById(id);
        if(users==null){
            return ResponseResult.errorResult(400,"未找到对应ID的用户");
        }
        users.setStatus(users.getStatus()==0?1:0);
        int update = usersMapper.updateUserStatusById(users);
        if (update>0){
            return ResponseResult.okResult("更新成功");
        }else {
            return ResponseResult.errorResult(500,"更新失败");
        }
    }



}





